package com.echo.servlet.UserServlet;

import com.echo.entity.User;
import com.echo.servlet.BaseServlet;
import com.echo.util.SessionUtils;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/profile/edit")
public class ProfileEditServlet extends BaseServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // 1. 设置编码
        setRequestEncoding(request);
        
        // 2. 校验登录状态
        if (!checkLogin(request, response)) {
            return;
        }
        
        // 3. 获取当前登录用户信息并传递给页面
        User loginUser = SessionUtils.getCurrentUser(request);
        request.setAttribute("user", loginUser);
        
        // 4. 转发到profile.html页面
        forward(request, response, "/profile.html");
    }
}